import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select

testCase = "DBshop009销售管理退货管理搜索"
rootPath=get_pro_rootpath() #获取项目的绝对路径
filePath=rootPath+r'\public\order1.txt' #拼接文件路径
orderId=readFile(filePath) #读取文件内容
print(orderId)   #打印订单编号

firefox = openBrowser(url)
DBshopLogin(firefox,userName,password)
firefox.find_element_by_link_text("用户中心").click()
firefox.find_element_by_link_text("退货申请").click()
firefox.find_element_by_link_text("点此申请退货").click()
firefox.find_element_by_id("order_sn").send_keys(orderId)
firefox.find_element_by_id("search-order").click()
firefox.find_element_by_id("refund_info").send_keys("退款")
time.sleep(3)
firefox.find_element_by_xpath("//button[@class='btn btn-primary']").click()
time.sleep(3)
firefox.switch_to.alert.accept()

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'销售管理','退货管理')
firefox.find_element_by_xpath("//input[@name='order_sn']").send_keys(orderId)
K = firefox.find_element_by_xpath("//select[@name='refund_type']")
ActionChains(firefox).move_to_element(K).perform()
Select(K).select_by_visible_text("退款到账户余额")
firefox.find_element_by_xpath("//button").click()
time.sleep(3)
try:
    firefox.find_element_by_xpath('//td[text()="退款到账户余额"]/following-sibling::td/a' ).text
    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()
























